import logging

from flask import Flask, render_template, request

app = Flask(__name__, static_url_path="")


@app.route("/")
def index():
    return render_template("Home.html")


@app.route("/about")
def about():
    return render_template("About.html")


@app.route("/product")
def product():
    return render_template("Product.html")

@app.route("/team")
def team():
    return render_template("Team.html")

@app.route("/contact")
def contact():
    return render_template("Contact.html")

@app.route("/subscribe", methods=["POST"])
def subscribe():
    logging.info("email:"+request.form.get("email"))
    return render_template("Home.html", js="alert('订阅成功')")


@app.route("/contact_msg", methods=["POST"])
def contact_msg():
    content = request.form.get("Name")+"$$"+request.form.get("Email")\
              +"$$"+request.form.get("Subject")+"$$"+request.form.get("Message")
    with open("./static/contact.txt", mode="a+", encoding="utf-8") as file:
        file.write(content+"\n")
    return render_template("Contact.html", js="alert('发送完成')")
if __name__ == '__main__':
    app.run(port=8500, host="0.0.0.0", debug=True)





